package cn.bbs.ba.error;

import java.util.HashMap;

import cn.bbs.ba.dao.BAADaoOperate;
import cn.bbs.ba.db.Fetcher;

public class Message {
	
	private static HashMap<String, DTOMessage> msgsMap = new HashMap<String, DTOMessage>();
	
	
    public static DTOMessage getMsg(final String strMsgId) {
        return msgsMap.get(strMsgId);
    }
    
    public static void initMsg() {
    	HashMap<String, String> strMap = new HashMap<String, String>();
    	strMap.put(BAADaoOperate.SQL_ID, "searchMsgInfo");
    	DTOMessage dto = null;
    	Fetcher<DTOMessage> dtoFetch = BAADaoOperate.search(strMap,  DTOMessage.class);
    	for (int i = 1; i <= dtoFetch.size(); i++) {
    		dto = dtoFetch.get(i);
    		msgsMap.put(dto.getMsgId(), dto);
    	}
    }
    
//    public static DTOMessage getMsg(final String strMsgId) {
//    	HashMap<String, String> strMap = new HashMap<String, String>();
//    	strMap.put(BAADaoOperate.SQL_ID, "searchMsgInfo");
//    	strMap.put("MSGID", strMsgId);
//    	DTOMessage dto = null;
//    	Fetcher<DTOMessage> dtoFetch = BAADaoOperate.search(strMap,  DTOMessage.class);
//    	if (dtoFetch.size() > 0) {
//    		dto = dtoFetch.get(1);
//    	}
//        return dto;
//    }
    
}
